import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
time.sleep(2)
driver.find_element(By.LINK_TEXT, "新闻").click()
print(driver.title)
kw = driver.window_handles[1]
print(kw)
driver.switch_to.window(kw)
print(driver.title)
time.sleep(2)

time.sleep(3)
driver.quit()